package com.example.spliterator;

import org.junit.Test;

import java.util.Spliterator;
import java.util.function.IntConsumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 *
 *
 * @author qingyan 2021-11-09
 */
public class SpliteratorsTest {



    @Test
    public void test1(){
        Spliterator.OfInt spliterator = IntStream.iterate(1, i -> ++i)
                .limit(100000)
                .parallel()
                .spliterator();
        spliterator.trySplit();
        spliterator.tryAdvance(new IntConsumer() {
            @Override
            public void accept(int value) {
                System.out.println(value);
            }
        });
        spliterator.trySplit();
        spliterator.tryAdvance(new IntConsumer() {
            @Override
            public void accept(int value) {
                System.out.println(value);
            }
        });
        Stream.of("1", "2", "3").collect(Collectors.joining("", "", ""));

    }
}
